<?php
/* -----------------------------------------------------------------
* 	ID:						$Id: cseo_java.php 15 2011-02-24 15:42:46Z akausch $
* 	Letzter Stand:			$Revision: 15 $
* 	zuletzt geändert von: 	$Author: akausch $
* 	Datum:					$Date: 2011-02-24 16:42:46 +0100 (Do, 24. Feb 2011) $
*
* 	commerce:SEO by Webdesign Erfurt
* 	http://www.commerce-seo.de
*
* 	Copyright (c) since 2010 commerce:SEO
* ------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* --------------------------------------------------------------- */

include_once(DIR_WS_CLASSES.'EvalMath.Class.php');
include_once(DIR_WS_CLASSES.'SourceMerger.Class.php');
include_once(DIR_WS_CLASSES.'CSS.Class.php');
include_once(DIR_WS_CLASSES.'JavaScript.Class.php');

$js = new JavaScript(true, false, false);

$js_source[] = 'jquery-1.6.2';
$js_source[] = 'twitter_widget';
$js_source[] = 'jquery.tooltip_cseov21';
#$js_source[] = 'jquery.easing.1.3.pack';

if ($mobile_template == 'True') {
$js_source[] = 'jquery.mobile-1.0b2';
$js_source[] = 'mobile';
$css_file[] = 'jquery.mobile-1.0b2.min';
}

if(strpos($PHP_SELF, FILENAME_CHECKOUT_PAYMENT) === 0)
	echo $payment_modules->javascript_validation();
	
if(strpos($PHP_SELF, FILENAME_CREATE_ACCOUNT) === 0 ||
strpos($PHP_SELF, FILENAME_CREATE_GUEST_ACCOUNT) === 0 || 
strpos($PHP_SELF, FILENAME_ACCOUNT_PASSWORD) === 0 || 
strpos($PHP_SELF, FILENAME_ACCOUNT_EDIT) === 0 || 
(strpos($PHP_SELF, FILENAME_ADDRESS_BOOK_PROCESS) === 0 && (isset($_GET['delete']) == false)) || 
(strpos($PHP_SELF, FILENAME_CHECKOUT_SHIPPING_ADDRESS) === 0 || strpos($PHP_SELF,FILENAME_CHECKOUT_PAYMENT_ADDRESS) === 0)) {
	$js->setData('js_error', xtc_js_lang(JS_ERROR));
	$js->setData('js_error_submitted', xtc_js_lang(JS_ERROR_SUBMITTED));
	if(ACCOUNT_GENDER == 'true')
		$js->setData('entry_gender_error', '  check_radio("gender", "' . ENTRY_GENDER_ERROR . '");');
	else
		$js->setData('entry_gender_error', '');
		$js->setData('entry_first_name', ENTRY_FIRST_NAME_MIN_LENGTH.',"'.xtc_js_lang(ENTRY_FIRST_NAME_ERROR).'"');
		$js->setData('entry_last_name', ENTRY_LAST_NAME_MIN_LENGTH.',"'.xtc_js_lang(ENTRY_LAST_NAME_ERROR).'"');
	if(ACCOUNT_DOB == 'true')
		$js->setData('dob', ' check_input("dob", ' . ENTRY_DOB_MIN_LENGTH . ', "' . xtc_js_lang(ENTRY_DATE_OF_BIRTH_ERROR) . '");');
	else
		$js->setData('', '');
		$js->setData('mail_address', ENTRY_EMAIL_ADDRESS_MIN_LENGTH.', "'.xtc_js_lang(ENTRY_EMAIL_ADDRESS_ERROR).'"');
		$js->setData('street', ENTRY_STREET_ADDRESS_MIN_LENGTH.', "'. xtc_js_lang(ENTRY_STREET_ADDRESS_ERROR).'"');
		$js->setData('postcode', ENTRY_POSTCODE_MIN_LENGTH.', "'.xtc_js_lang(ENTRY_POST_CODE_ERROR).'"');
		$js->setData('city', ENTRY_CITY_MIN_LENGTH.', "'.xtc_js_lang(ENTRY_CITY_ERROR).'"');
	if(ACCOUNT_STATE == 'true')
		$js->setData('state', '  check_input("state", ' . ENTRY_STATE_MIN_LENGTH . ', "' . xtc_js_lang(ENTRY_STATE_ERROR) . '");');
	else
		$js->setData('state', '');
		$js->setData('country', xtc_js_lang(ENTRY_COUNTRY_ERROR));
		$js->setData('telephone', ENTRY_TELEPHONE_MIN_LENGTH.', "'.xtc_js_lang(ENTRY_TELEPHONE_NUMBER_ERROR).'"');
		$js->setData('password', ENTRY_PASSWORD_MIN_LENGTH.', "'.xtc_js_lang(ENTRY_PASSWORD_ERROR).'", "'.xtc_js_lang(ENTRY_PASSWORD_ERROR_NOT_MATCHING).'"');
		$js->setData('password_new', xtc_js_lang(ENTRY_PASSWORD_MIN_LENGTH).', "'.xtc_js_lang(ENTRY_PASSWORD_ERROR).'", "'.xtc_js_lang(ENTRY_PASSWORD_NEW_ERROR).'", "'.xtc_js_lang(ENTRY_PASSWORD_NEW_ERROR_NOT_MATCHING).'"');
		$js_source[] = 'form_check';
} elseif(strpos($PHP_SELF, FILENAME_ADVANCED_SEARCH) === 0 || strstr($_SERVER['REQUEST_URI'], FILENAME_ADVANCED_SEARCH) === 0) {
	$js->setData('js_error', xtc_js_lang(JS_ERROR));
	$js->setData('js_at_least_one_input', xtc_js_lang(JS_AT_LEAST_ONE_INPUT));
	$js->setData('js_price_from_must_be_num', xtc_js_lang(JS_PRICE_FROM_MUST_BE_NUM));
	$js->setData('js_price_to_must_be_num', xtc_js_lang(JS_PRICE_TO_MUST_BE_NUM));
	$js->setData('js_price_to_less_than_price_from', xtc_js_lang(JS_PRICE_TO_LESS_THAN_PRICE_FROM));
	$js_source[] = 'advanced_search';
}

elseif(((isset($_GET['products_id'])) && (!empty($_GET['products_id'])) ) || (SHIPPING_LINK == 'overlay') || (SITE_OVERLAYS == 'true')) {
	$js_source[] = 'jquery.fancybox-1.3.1.pack';
	$js_source[] = 'jquery.mousewheel-3.0.2.pack';
	
	if((isset($_GET['products_id'])) && (!empty($_GET['products_id'])) ) {
		if ($mobile_template == 'False') {
			$js_source[] = 'fancybox_produkt';
			$js_source[] = 'jqzoom.pack.1.0.1';
			$js_source[] = 'product_info';
			$js_source[] = 'jquery.prettyGallery';
			$js_source[] = 'jquery.prettyPhoto';
			$js_source[] = 'jyuotube';
			$js_source[] = 'jquery-ui-1.8.11.custom.min';
			$css_file[] = 'jquery.ui.tabs';
			$css_file[] = 'fancybox';
			$css_file[] = 'jqzoom';
			$css_file[] = 'rating';
			$css_file[] = 'prettyGallery';
			$css_file[] = 'prettyPhoto';
		} else {
			$js_source[] = 'product_info_mobile';
		}
	}
	if(SHIPPING_LINK == 'overlay' && SITE_OVERLAYS == 'true') {
		$css_file[] = 'fancybox';
		$js_source[] = 'fancybox_overlay';
	}
} 

if ((strpos($_GET['site'], FILENAME_PRODUCT_REVIEWS_WRITE) === 0) || (isset($_GET['products_id']))) {
	$js_source[] = 'jquery.rating.pack';
	$js->setData('js_error', xtc_js_lang(JS_ERROR));
	$js->setData('js_review_text', xtc_js_lang(JS_REVIEW_TEXT));
	$js->setData('js_review_rating', xtc_js_lang(JS_REVIEW_RATING));
	$js->setData('js_review_lenght', REVIEW_TEXT_MIN_LENGTH);
	$js_source[] = 'rating_form_check';
}

if(!isset($_GET['products_id']) && (isset($_GET['cPath'])) && ($_SESSION['customers_status']['customers_status_read_reviews'] != 0)) { 
	if (DISPLAY_NEW_PRODUCTS_SLIDE == 'true') {
		$js_source[] = 'jquery.scrollable-1.0.2.min';
		$css_file[] = 'scrollable';
	}
}

if(!isset($_GET['products_id']) && (!isset($_GET['cPath']))) { 
	if (DISPLAY_NEW_PRODUCTS_SLIDE == 'true') {
		$js_source[] = 'jquery.scrollable-1.0.2.min';
		$css_file[] = 'scrollable';
	}
}

if(isset($_GET['blog_cat']) && isset($_GET['blog_item'])) {
	if(BLOG_CAPTCHA == 'ja')
		$js->setData('blog_captcha', 'var poststr = '.(($_SESSION['customer_first_name'] == '') ? '"name=" + encodeURIComponent( document.getElementById("name").value ) + \'' :''). ' "&text=" + encodeURIComponent( document.getElementById("text").value ) + "&blog_id=" + encodeURIComponent( document.getElementById("blog_id").value) + "&captcha=" + encodeURIComponent( document.getElementById("captcha").value);');
	else
		$js->setData('blog_captcha', 'var poststr = '.(($_SESSION['customer_first_name'] == '') ? '"name=" + encodeURIComponent( document.getElementById("name").value ) + \'':'').' "&text=" + encodeURIComponent( document.getElementById("text").value ) + "&blog_id=" + encodeURIComponent(document.getElementById("blog_id").value);');
	$js->setData('url', HTTP_SERVER.DIR_WS_CATALOG);
	$js->setData('template', CURRENT_TEMPLATE);
	$js_source[] = 'blog';	
	$css_file[] = 'blog';
}
if ($mobile_template == 'False') {
	if(CSS_BUTTON_ACTIVE != 'true')
		$js_source[] = 'hover_button';
}

$js_source[] = 'main';
$js_source[] = 'produkt_filter';

#Basis CSS
$browser_css[] = 'reset';
$browser_css[] = 'janolaw';
$browser_css[] = 'struktur';
$browser_css[] = 'stylesheet';
$browser_css[] = 'boxen';

#Browserspezifische und Seiten CSS



if((isset($_GET['products_id'])) && (!empty($_GET['products_id'])) ) 
{
	#$template_css->addFiles(array('product_info'), 'product_info', $cache_name);
	$browser_css[] = 'product_info';
}

if(!isset($_GET['products_id']) && (isset($_GET['cPath'])) || strstr($PHP_SELF, FILENAME_ADVANCED_SEARCH_RESULT ))
{
	#$template_css->addFiles(array('product_listing'), 'product_listing', $cache_name);
	$browser_css[] = 'product_listing';
}



if(strstr($_SERVER['REQUEST_URI'], FILENAME_CHECKOUT) || strstr($_SERVER['REQUEST_URI'], FILENAME_CHECKOUT_CONFIRMATION) || strstr($_SERVER['REQUEST_URI'], FILENAME_CHECKOUT_PAYMENT) || strstr($_SERVER['REQUEST_URI'], FILENAME_CHECKOUT_SHIPPING) || strstr($_SERVER['REQUEST_URI'], FILENAME_WISH_LIST) || strstr($_SERVER['REQUEST_URI'], 'wish_list.php') || strstr($_SERVER['REQUEST_URI'], FILENAME_CHECKOUT_SUCCESS))
{
	#$template_css->addFiles(array('checkout', 'shopping_cart'), 'checkout', $cache_name);
	$browser_css[] = 'checkout';
	$browser_css[] = 'shopping_cart';
}

$browser = $_SERVER[HTTP_USER_AGENT];


if(!preg_match("'MSIE ([0-8].[0-9]{1,2})'",$browser,$matched) && !preg_match("'Jigsaw'",$browser,$matched)) {
	#$template_css->addFiles(array('css3_browser'), 'css3_browser', $cache_name);
	$browser_css[] = 'css3_browser';
}

if(isset($_GET['products_id']))
	$cache_name = md5($PHP_SELF.'p'.$_SESSION['languages_id']);
elseif(isset($_GET['cPath']))
	$cache_name = md5($PHP_SELF.'c'.$_SESSION['languages_id']);
else
	$cache_name = md5($PHP_SELF.$_SESSION['languages_id']);

$bDevMode = true;
$template_css = new CSS(!$bDevMode, false);
if ($mobile_template == 'False') {
	$template_css->setUrl('templates/'.CURRENT_TEMPLATE.'/cache');
	$template_css->setSourcePath('templates/'.CURRENT_TEMPLATE.'/css');
	$template_css->setCachePath('templates/'.CURRENT_TEMPLATE.'/cache');
} else {
	$template_css->setUrl('templates/'.CURRENT_MOBILE_TEMPLATE.'/cache');
	$template_css->setSourcePath('templates/'.CURRENT_MOBILE_TEMPLATE.'/css');
	$template_css->setCachePath('templates/'.CURRENT_MOBILE_TEMPLATE.'/cache');
}

#$template_css->addFiles(array('reset', 'janolaw', 'struktur', 'stylesheet', 'boxen'), 'stylesheet', $cache_name);
$template_css->addFiles($browser_css, 'stylesheet', $cache_name);

if(strstr($_SERVER['REQUEST_URI'], FILENAME_SHOPPING_CART) || strstr($_SERVER['REQUEST_URI'], FILENAME_WISH_LIST))
{
	$template_css->addFiles(array('shopping_cart'), 'shopping_cart', $cache_name);
	#$browser_css[] = 'shopping_cart';
}

if(strstr($_SERVER['REQUEST_URI'], FILENAME_CREATE_ACCOUNT) || strstr($_SERVER['REQUEST_URI'], FILENAME_CREATE_GUEST_ACCOUNT) || strstr($_SERVER['REQUEST_URI'], FILENAME_ACCOUNT_PASSWORD) || strstr($_SERVER['REQUEST_URI'], FILENAME_ACCOUNT_EDIT)) 
{
	$template_css->addFiles(array('account'), 'account', $cache_name);
	#$browser_css[] = 'account';
}

#$template_css->addFiles(array('create_account'), 'create_account', $cache_name);
# $template_css->addFiles(array('print'), 'print', '.default', 'print'); // wird derzeit noch nicht gebraucht


if(preg_match("'MSIE ([0-6].[0-9]{1,2})'",$browser,$matched)) {
	$js_source[] = 'ie6fix-min';
}

if(preg_match("'MSIE ([0-8].[0-9]{1,2})'",$browser,$matched)) {
	$js_source[] = 'html5';
	$template_css->addFiles('ie', 'ie', '', '', 'IE');
	$template_css->addFiles('ie7', 'ie7', '', '', 'IE 7');	
}


$js_css = new CSS(true, false);
$js_css->setUrl('cache');
$js_css->setSourcePath('includes/javascript/css');
$js_css->setCachePath('cache');
$js_css->addFiles($css_file, 'js', $cache_name);

#echo '<link rel="stylesheet" type="text/css" media="screen" href="css_styler.php" />'."\n";

$js->setUrl('cache');
$js->setSourcePath('includes/javascript/js');
$js->setCachePath('cache');
$js->addFiles($js_source, 'js', $cache_name);

echo $js_css->linkFiles();
echo $template_css->linkFiles();
echo $js->linkFiles();
?>